Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 15, 2025

This PR implements automatic VERSION file updates with GitVersion semver on each checkout, allowing developers to easily see what version they're currently working on.

Changes Made

1. Created VERSION File

  • Added a VERSION file in the repository root that gets automatically updated
  • Initially set to 1.0.0 and managed by the version update system

2. Version Update Script

Created update-version.sh that intelligently determines the current version:

# Tries GitVersion first for proper semver calculation
dotnet-gitversion -config .gitversion -showvariable MajorMinorPatch

# Falls back to git describe when GitVersion returns defaults
git describe --tags --always --dirty

The script handles various scenarios:

  • GitVersion available: Uses calculated semver from GitVersion configuration
  • GitVersion returns default (1.0.0): Falls back to extracting version from git tags
  • Git describe: Extracts meaningful version from tag patterns like feature_larasets_5.10.25.10.2-2-g51926a7
  • Error handling: Maintains existing VERSION file if no version can be determined

3. Enhanced Post-Checkout Hook

Modified src/githooks/_post-checkout.sh to automatically call the version update script:

# Update VERSION file with current GitVersion semver
if [ -f "./update-version.sh" ]; then
  ./update-version.sh || zz_log w "Failed to update VERSION file"
else
  zz_log w "update-version.sh script not found, skipping VERSION file update"
fi

How It Works

  1. On Checkout: The post-checkout hook runs automatically when switching branches/commits
  2. Version Detection: The script determines the current version using GitVersion or git describe fallback
  3. File Update: The VERSION file is updated with the detected semver
  4. Developer Visibility: Developers can run cat VERSION to see their current working version

Example Usage

# After checking out any branch
$ cat VERSION
5.10.2-3-g51926a7

# The file automatically updates on checkout
$ git checkout main
$ cat VERSION
5.10.3-1-g8a2b3c4

This integrates seamlessly with the existing GitVersion configuration and devcontainer features workflow, requiring no manual intervention once the githooks feature is installed and configured.

Fixes #10.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] VERSION file update feat: add VERSION file update with gitversion semver on checkout Sep 15, 2025
@Copilot Copilot AI requested a review from tomgrv September 15, 2025 21:26
@tomgrv tomgrv self-requested a review September 15, 2025 21:30
Copy link
Owner

@tomgrv tomgrv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot update package version

@tomgrv tomgrv marked this pull request as ready for review September 18, 2025 09:43
@Copilot Copilot AI review requested due to automatic review settings September 18, 2025 09:43
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements automatic VERSION file updates using GitVersion semver on checkout to provide developers with visibility into their current working version.

  • Added a VERSION file that gets automatically updated with semver information
  • Created an intelligent version update script that tries GitVersion first, then falls back to git describe
  • Enhanced the post-checkout hook to automatically update the VERSION file on branch/commit switches

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
update-version.sh New script that determines current version using GitVersion or git describe fallback
src/githooks/_post-checkout.sh Enhanced to call the version update script automatically
VERSION New file containing the current version string

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@tomgrv tomgrv self-requested a review September 21, 2025 07:48
Copy link
Owner

@tomgrv tomgrv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le fichier version ne doit pas être comité dans le repos

@tomgrv tomgrv merged commit 457605c into main Sep 22, 2025
1 check passed
@tomgrv tomgrv deleted the copilot/fix-10 branch September 22, 2025 16:02
tomgrv pushed a commit that referenced this pull request Sep 23, 2025
* Initial plan

* feat: add VERSION file update with gitversion semver on checkout

Co-authored-by: tomgrv <[email protected]>

* fix: improve version extraction logic for better semver detection

Co-authored-by: tomgrv <[email protected]>

* feat: add VERSION file update with gitversion semver on checkout

Co-authored-by: tomgrv <[email protected]>

* feat: support flexible naming

Co-authored-by: Copilot <[email protected]>

* fix: 🐛 handle legitimate naming

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VERSION file update
2 participants